/*
 * Copyright (C) 2012 Robot.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.yfz.bussearch;

import com.yfz.bussearch.ui.AboutDialog;
import com.yfz.bussearch.ui.LocalSearch;
import com.yfz.bussearch.ui.WebSearch;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class BusSearch extends Activity {
    /** Called when the activity is first created. */
	private static Thread thread;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button button_wap = (Button)findViewById(R.id.id_button_1);
        button_wap.setOnClickListener(onclick_wap);
        
        Button button_local = (Button)findViewById(R.id.id_button_2);
        button_local.setOnClickListener(onclick_wap);
    }
    
    OnClickListener onclick_wap = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			switch(v.getId()) {
				case R.id.id_button_1:
					Intent intent1 = new Intent(BusSearch.this, WebSearch.class);
					startActivity(intent1);
					break;
				case R.id.id_button_2:
					Intent intent2 = new Intent(BusSearch.this, LocalSearch.class);
					startActivity(intent2);
					break;
			}
		}
	};

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuItem mitem = menu.add(0,0,0,R.string.about);
		mitem.setIcon(R.drawable.icon_menu_about);
		return true;
	}
	
	//以下两种方法都可以监听
	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		if(item.getItemId() == 0) {
			AboutDialog.show(this);
		}
		return super.onMenuItemSelected(featureId, item);
	}
	
//	@Override
//	public boolean onOptionsItemSelected(MenuItem item) {
//		return true;
//	}
}